package com.hengpeng.itfints.config;

/**
 * <pre>
 * 玩法之间的不同配置
 * </pre>
 * @author CHARLES
 * @version 1.0, 2011-6-16
 */
public class PageConfig
{
	public static final String PREFIX_KEY = "page";

	public static final String PREFIX_DEFAULT = "default";

	public static final String PREFIX_MAX_MULTIPLE = "maxMultiple";

	public static final String PREFIX_MAX_PRICE = "maxPrice";

	public static final String PREFIX_MAX_LOT_COUNT = "maxLotCount";

	public static final String PREFIX_BONUS_LEVEL = "bonuslevel";

	public static String getGameConfig(String key, Integer gameId, String storeId)
	{
		String prefixConfig = PREFIX_KEY + "." + key;

		String keyConfig = prefixConfig + "." + storeId + "." + String.valueOf(gameId);

		String value = Configuration.getValue(keyConfig);
		if (value == null)
		{
			value = Configuration.getValue(prefixConfig + "." + PREFIX_DEFAULT + "." + gameId);
			if (value == null)
			{
				value = Configuration.getValue(prefixConfig + "." + storeId + "." + PREFIX_DEFAULT);
			}
			if (value == null)
			{
				value = Configuration.getValue(prefixConfig + "." + PREFIX_DEFAULT + "." + PREFIX_DEFAULT);
			}
			if (value == null)
			{
				value = Configuration.getValue(prefixConfig + "." + PREFIX_DEFAULT);
			}
		}
		return value;
	}

	public static Integer getGameMaxPrice(Integer gameId, String storeId)
	{
		return Integer.valueOf(getGameConfig(PREFIX_MAX_PRICE, gameId, storeId));
	}

	public static Integer getGameMaxMultiple(Integer gameId, String storeId)
	{
		return Integer.valueOf(getGameConfig(PREFIX_MAX_MULTIPLE, gameId, storeId));
	}

	public static Integer getGameMaxLotCount(Integer gameId, String storeId)
	{
		return Integer.valueOf(getGameConfig(PREFIX_MAX_LOT_COUNT, gameId, storeId));
	}

	public static String getBonusLevelStr(Integer gameId, Long level)
	{
		String key = PREFIX_KEY + "." + PREFIX_BONUS_LEVEL;
		String value = Configuration.getValue(key + "." + gameId + "." + level);
		if (value == null)
		{
			value = Configuration.getValue(key + "." + PREFIX_DEFAULT + "." + level);
		}
		return value;
	}

}
